/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('modelservice', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetMonthAmountRequest {
  sceneType?: string(name='SceneType', description='This parameter is required.'),
}

model GetMonthAmountResponseBody = {
  backgroundAmount?: int32(name='BackgroundAmount'),
  postpayAmount?: int32(name='PostpayAmount'),
  prepayAmount?: int32(name='PrepayAmount'),
  requestId?: string(name='RequestId'),
  totalAmount?: int32(name='TotalAmount'),
}

model GetMonthAmountResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetMonthAmountResponseBody(name='body'),
}

/**
 * @summary 获取当月的使用量
 *
 * @param request GetMonthAmountRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetMonthAmountResponse
 */
async function getMonthAmountWithOptions(request: GetMonthAmountRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetMonthAmountResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.sceneType)) {
    query['SceneType'] = request.sceneType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetMonthAmount',
    version = '2022-06-14',
    protocol = 'HTTPS',
    pathname = `/api/v1/statistics/month/amount`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取当月的使用量
 *
 * @param request GetMonthAmountRequest
 * @return GetMonthAmountResponse
 */
async function getMonthAmount(request: GetMonthAmountRequest): GetMonthAmountResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getMonthAmountWithOptions(request, headers, runtime);
}

model GetUserRequest {
  sceneType?: string(name='SceneType', example='image_label'),
}

model GetUserResponseBody = {
  appId?: string(name='AppId', example='20200425******'),
  code?: string(name='Code', example='OK'),
  host?: string(name='Host', example='ai-service.******.alicontainer.com'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='897658D5-1FB8-5CFA-A030-727CCAE59EB0'),
  token?: string(name='Token', example='Njk0Njk******'),
}

model GetUserResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetUserResponseBody(name='body'),
}

/**
 * @summary 获取user相关的appid, token等信息
 *
 * @param request GetUserRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetUserResponse
 */
async function getUserWithOptions(request: GetUserRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetUserResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.sceneType)) {
    query['SceneType'] = request.sceneType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetUser',
    version = '2022-06-14',
    protocol = 'HTTPS',
    pathname = `/api/v1/user/info`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取user相关的appid, token等信息
 *
 * @param request GetUserRequest
 * @return GetUserResponse
 */
async function getUser(request: GetUserRequest): GetUserResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getUserWithOptions(request, headers, runtime);
}

model ListDayAmountRequest {
  endTime?: string(name='EndTime'),
  sceneType?: string(name='SceneType', example='sales_pick'),
  startTime?: string(name='StartTime', description='This parameter is required.'),
}

model ListDayAmountResponseBody = {
  dayAmounts?: [ 
    {
      amount?: int32(name='Amount'),
      date?: string(name='Date'),
    }
  ](name='DayAmounts'),
  requestId?: string(name='RequestId'),
}

model ListDayAmountResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListDayAmountResponseBody(name='body'),
}

/**
 * @summary 每天的调用量列表
 *
 * @param request ListDayAmountRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListDayAmountResponse
 */
async function listDayAmountWithOptions(request: ListDayAmountRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListDayAmountResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.sceneType)) {
    query['SceneType'] = request.sceneType;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDayAmount',
    version = '2022-06-14',
    protocol = 'HTTPS',
    pathname = `/api/v1/statistics/day/amount`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 每天的调用量列表
 *
 * @param request ListDayAmountRequest
 * @return ListDayAmountResponse
 */
async function listDayAmount(request: ListDayAmountRequest): ListDayAmountResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listDayAmountWithOptions(request, headers, runtime);
}

model ListRechargeBillsRequest {
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  sceneType?: string(name='SceneType', example='sales_pick'),
}

model ListRechargeBillsResponseBody = {
  instanseInfos?: [ 
    {
      currTimes?: int32(name='CurrTimes'),
      gmtEndTime?: string(name='GmtEndTime'),
      initTimes?: int32(name='InitTimes'),
      instanceId?: string(name='InstanceId'),
      source?: string(name='Source'),
    }
  ](name='InstanseInfos'),
  requestId?: string(name='RequestId'),
  residueAmount?: int32(name='ResidueAmount'),
  totalCount?: int32(name='TotalCount'),
}

model ListRechargeBillsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListRechargeBillsResponseBody(name='body'),
}

/**
 * @summary 用户充值列表
 *
 * @param request ListRechargeBillsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListRechargeBillsResponse
 */
async function listRechargeBillsWithOptions(request: ListRechargeBillsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListRechargeBillsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sceneType)) {
    query['SceneType'] = request.sceneType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListRechargeBills',
    version = '2022-06-14',
    protocol = 'HTTPS',
    pathname = `/api/v1/statistics/rechargebills`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 用户充值列表
 *
 * @param request ListRechargeBillsRequest
 * @return ListRechargeBillsResponse
 */
async function listRechargeBills(request: ListRechargeBillsRequest): ListRechargeBillsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listRechargeBillsWithOptions(request, headers, runtime);
}

